<template>
  <div class="topbar">
    <div class="w topbarWrap">
      <div class="l">欢迎来到叩丁狼积分商城</div>
      <ul class="r">
        <li>
          <img
            class="avatar"
            src="../assets/img/userImg.f8bbec5e.png"
            width="26"
            alt=""
          />
          用户名：--
        </li>
        <li>我的鸡腿：--</li>
        <li>获取鸡腿</li>
        <li>叩丁狼官网</li>
        <li class="login-btn" @click="changeIsShowLogin" v-show="!isShowCart">
          登录
        </li>
        <li class="login-btn" v-show="isShowCart">
          <img src="../assets/img/cart.png" alt="" />
          <span class="cart">购物车</span>
          <span class="num">0</span>
        </li>
      </ul>
    </div>
  </div>
</template>

<script>
import { mapMutations, mapState } from "vuex";
export default {
  name: "Topbar",
  methods: {
    ...mapMutations("loginModule", ["changeIsShowLogin"]),
  },
  computed: {
    ...mapState("showCartModule", ["isShowCart"]),
  },
};
</script>

<style lang="less" scoped>
.topbar {
  height: 40px;
  line-height: 40px;
  background: #242b39;
  font-size: 14px;
  font-family: SourceHanSansSC-Light;
  .topbarWrap {
    color: #fffefe;
    display: flex;
    justify-content: space-between;
    .r {
      li {
        float: left;
        margin-left: 20px;
        text-align: center;
        cursor: pointer;
        &.login-btn {
          width: 124px;
          height: 40px;
          background: #0a328e;
          display: flex;
          align-items: center;
          justify-content: center;
        }
        .cart {
          margin: 0 10px;
        }
        .num {
          display: inline-block;
          background-color: red;
          color: #fff;
          width: 20px;
          height: 20px;
          line-height: 20px;
          border-radius: 50%;
        }
      }
      .avatar {
        vertical-align: middle;
        border-radius: 50%;
      }
    }
  }
}
</style>